//
//  Content.h
//  etionLib
//
//  Created by xqls on 12-5-15.
//  Copyright (c) 2012年 GuangZhouXuanWu. All rights reserved.
//

#import <Foundation/Foundation.h>

#define		SYSCFGF				@"syscfg"
#define		SYSCFGFE			@"syscfg.plist"

//////////////////////////////////
/**
 *  更新信息，字典结构
 */
extern NSString *const  XLGContextUpdateInfo;
/**
 *  发现新版本后是否进行弹出提示
 */
extern NSString *const  XLGContextUpdateInfoRemind;
/**
 *  是否有新版本
 */
extern NSString *const  XLGContextUpdateInfoNewTag;
/**
 *  是否进行强制更新
 */
extern NSString *const  XLGContextUpdateInfoForceUpdate;
/**
 *  新版本显示的名字
 */
extern NSString *const  XLGContextUpdateInfoNewVersionName;
/**
 *  新版本的下载地址
 */
extern NSString *const  XLGContextUpdateInfoNewVersionHttp;
/**
 *  新版本的更新的内容信息
 */
extern NSString *const  XLGContextUpdateInfoTip;
//////////////////////////////////

#define		VERSIONNAMET		@"versionname"
#define		VERSIONNOT			@"versionno"
#define		BUILDNOT			@"buildno"
#define		CLIENTTYPENOT		@"clienttypeno"

#define     GETUSERINFO         @"userinfo"

/**
 *  是否第一次运行
 */
extern NSString *const XLGContentIsFirstRun;

#define     EXTENDKEY           @"extendkey"

#define     MULTIMUSERGATEWAY   @"multiusergateway"

/**
 *  http接口请求地址
 */
extern NSString *const XLGContextHTTPaddress;

/**
 *  文件(图片)下载地址服务器地址
 */
extern NSString *const XLGContextFileHTTPAddress;

/**
 *  指定登录模式是否为SSO模式
 */
extern NSString *const  XLGContextLoginBySSO;


//////////////////////////////////
/**
 *  用于存储最近一次用户登录的相关信息，为字典结构
 */
extern NSString *const  XLGContextLastUser;
/**
 *  用于显示的字段的key
 */
extern NSString *const  XLGContextLastUserDisplayKey;
/**
 *  用于登录的字段的key
 */
extern NSString *const  XLGContextLastUserLoginKey;
/**
 *  存储具体的的用户信息的字典
 */
extern NSString *const  XLGContextLastUserInfo;
/**
 *  用户登录的E号
 */
extern NSString *const  XLGContextLastUserInfoUserNum;
/**
 *  用户的电话号码
 */
extern NSString *const  XLGContextLastUserInfoMobileNum;
/**
 * 用户的登录名
 */
extern NSString *const  XLGContextLastUserInfoLoginName;
/**
 *  用户的昵称，通常只用于显示在登录界面，不会用于真正登录
 */
extern NSString *const  XLGContextLastUserInfoNickName;
//////////////////////////////////

typedef NS_ENUM(NSInteger, XLGContextUserType)
{
    XLGContextUserTypeRegistered,
    XLGContextUserTypeTrial
};

@interface XLGContext : NSObject
{
    NSString  *m_token;
    NSInteger m_nUsernumber;
    NSString *m_szUsernumber;
    NSString *m_szAccountno;
    NSString *m_szPsw;
    NSString *m_szUserpath;
    BOOL m_bIsoffline;          //登录后的离线在线状态变化
    
    NSString *m_szVersionname;
    NSInteger m_nClienttypeno;
    NSInteger m_nBuildno;
    NSInteger m_nVersionno;
    NSInteger m_nMaxdownloading;
    BOOL m_bLogined;                //是否已经登录
    BOOL m_bIsofflinelogin;         //在登录界面，是否离线登录
    NSString *m_szDevicetoken;
    NSString *m_szUserdefaulteppath;
   
    BOOL m_bIsfirstrun;
    NSDictionary *m_dicExtendkey;
    
    NSString *_HTTPAddress;
 
    XLGContextUserType _userType;
    NSArray *_fileHTTPaddress;          //文件下载地址，0，源路径，1，缩略图路径，只对图片有效
    BOOL _hadNewVsersion;           //是否有新版本标记
    BOOL _forceUpdate;          //是否强制更新
}

@property(nonatomic, retain) NSString *m_token;
@property(nonatomic, assign) NSInteger m_nUsernumber;
@property(nonatomic, retain) NSString *m_szAccountno;
@property(nonatomic, retain) NSString *m_szPsw;
@property(nonatomic, retain) NSString *m_szUsernumber;
@property(nonatomic, retain) NSString *m_szUserpath;
@property(nonatomic, retain) NSString *m_szUserdefaulteppath;

@property(nonatomic, assign) BOOL m_bIsoffline;
@property(nonatomic, assign) BOOL m_bLogined;
@property(nonatomic, assign) BOOL m_bIsofflinelogin;

@property(nonatomic, retain) NSDictionary *m_dicLastuser;

@property(nonatomic, retain) NSString *HTTPaddress;

@property(nonatomic, retain) NSString *m_szVersionname;
@property(nonatomic, assign) NSInteger m_nClienttypeno;
@property(nonatomic, assign) NSInteger m_nBuildno;
@property(nonatomic, assign) NSInteger m_nVersionno;

@property(nonatomic, retain) NSString *m_szDevicetoken;
@property(nonatomic, assign) BOOL m_bIsfirstrun;
@property(nonatomic, retain) NSDictionary *m_dicExtendkey;
@property(nonatomic, assign) XLGContextUserType userType;
@property(nonatomic, retain, readonly) NSArray *fileHTTPaddress;
@property(nonatomic, assign) BOOL hadNewVsersion;
@property(nonatomic, assign) BOOL forceUpdate;
@property (nonatomic, assign) BOOL userSessionOut;


+ (void)loadSyscfgplist:(NSString *)szFilepath;

+ (void)saveFirstRun:(BOOL)bFirst;

+ (void)updateSyscfgplistCompletion:(void(^)(NSInteger nOldbuildno,NSInteger nNewbuildno))complete;

+ (BOOL)needUpdateSyscfg;

+ (NSArray*)needUpdateDatabase;

+ (NSDictionary*)getMainBundleSysCfgDictionary;

+ (NSDictionary*)getDocumentSysCfgDictionary;

+ (void)saveSysCfgValue:(id)value forKey:(NSString*)key;

+ (void)saveSysCfgValue:(NSDictionary*)dicValue;

+ (NSString*)fileDownloadURL:(NSString*)fileName;

+ (NSString*)thumbImageDownloadURL:(NSString*)fileName;

+ (void)remindNewVersion:(BOOL)remind;

+ (XLGContext *)context;

+ (void)releaseContext;

+ (void)clearContext;
@end
